--
-- Created by IntelliJ IDEA.
-- User: bluda
-- Date: 2018/9/10
-- Time: 12:11
-- To change this template use File | Settings | File Templates.
--


local FindPath = import("app.model.battlefield.FindPath")

local Unit1 = {
    position = {x=10,y=10},
    grid = {c=10,r=10}
}
local Unit2 = {
    position = {x=1,y=3},
    grid = {c=1,r=3}
}

local grid = {
    [10] = {0,0,0,0,0,0,0,0,0,0},  -- 1
    [9] =  {0,1,1,0,0,0,0,1,1,0},
    [8] =  {0,0,0,1,1,1,0,0,0,0},
    [7] =  {0,0,0,0,0,1,0,0,0,0},
    [6] =  {0,1,0,1,0,1,0,0,0,0},
    [5] =  {0,0,0,0,0,1,1,0,0,0},
    [4] =  {0,0,0,1,0,0,0,0,0,0},
    [3] =  {0,0,0,1,0,0,0,0,0,0},
    [2] =  {0,0,1,1,0,0,0,1,0,0},
    [1] =  {0,0,0,0,0,0,0,0,0,0},   -- 10
}

--
--for i = 0, 100 do
--    if Unit1.grid.c == Unit2.grid.c and Unit1.grid.r == Unit2.grid.r then
--    else
--        local a, c, r = FindPath:find(Unit1, Unit2, grid)
--        if a == nil then
--            logW("not found path")
--        else
--            Unit1.grid.c = c
--            Unit1.grid.r = r
--            Unit1.position.x = c
--            Unit1.position.y = r
--        end
--    end
--end



local s = Set()
local tt = {h1=1}
s:insert(tt)
s:insert("hi1")
s:insert("hi2")
s:insert("hi3")
s:insert("hi4")

for _,Value in ipairs(s) do
    print(Value)
end

print(s:find(tt))
s:remove(tt)
print(s:find(tt))

print(s:find("hi1"))
s:remove("hi1")
print(s:find("hi1"))

print(s:find("hi3"))
s:remove("hi3")
print(s:find("hi3"))

for _,Value in ipairs(s) do
    print(Value)
end



local xx = 1
print(type(xx))
local xx = "11"
print(type(xx))
local xx = true
print(type(xx))
local xx = function () return 1 end
print(type(xx))


local xxx = {
    tt=123
}

function xxx:pp()
    print("old")
end

local xv = extend(xxx)
function xv:pp()
    print("new")
end


xprint(xxx)
xprint(xv)
print(xxx:pp())
print(xv:pp())